<template>
  <a-modal
    :title="title"
    :width="width"
    :visible="visible"
    :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
    @ok="handleOk"
    @cancel="handleCancel"
    destroyOnClose
  >
    <JoinOrganization
      ref="modalForm"
      :showJoinTime="showJoinTime"
      :showLeaveTime="showLeaveTime"
      :editorType="editorType"
      :editable="editable"
      :editableFiexd="editableFiexd"
      :dataId="dataId"
      v-model="formData"
    ></JoinOrganization>
  </a-modal>
</template>

<script>
import { addOrganizationMember } from '@/api/api'
import JoinOrganization from './JoinOrganization'
export default {
  name: 'OrganizationMemberModal',
  components: {
    JoinOrganization
  },
  data() {
    return {
      title: '',
      width: 800,
      visible: false,
      disableSubmit: false,
      showJoinTime:false,
      showLeaveTime:false,
      editable: true,
      editableFiexd: {},
      formData: {},
      editorType:'',
      workflowModel: {
        operation: 'start'
      },
      dataId: '',
      successTxt: ''
    }
  },
  methods: {
    add(data) {
      this.visible = true
      this.showJoinTime = true
      this.showLeaveTime = true
      this.editorType = 'add'
      this.$nextTick(()=>{
          this.$refs.modalForm.add({
            ...data,
            actStatus:10
          })
      })
    },
    apply(data, editableFiexd) {
      this.title = '申请加入学生组织'
      this.visible = true
      this.editableFiexd = Object.assign({ userId: true }, editableFiexd)
      this.$nextTick(() => {
        this.$refs.modalForm.apply(data)
      })
    },
    edit(record) {
      this.visible = true
      this.title = '编辑'
      this.showJoinTime = true
      this.showLeaveTime = true
      this.editableFiexd = { userId: true }
      this.$nextTick(() => {
        this.$refs.modalForm.edit(record)
      })
    },
    review(record) {
      this.title = '查看'
      this.visible = true
      this.editable = false
      this.dataId =record.id
      // this.formData = record
      this.disableSubmit = true
    },
    close() {
      this.$emit('close')
      this.title = ''
      this.editable = true
      this.formData = {}
      this.editableFiexd = {}
      this.disableSubmit = false
      this.visible = false
      this.editorType = ''
      this.showJoinTime = false
      this.showLeaveTime = false
    },
    handleOk() {
      this.$refs.modalForm.submitForm().then(res => {
        this.$emit('ok')
        this.visible = false
      })
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style></style>
